package com.hdjk.view.callback;

import com.hdjk.view.entity.UserEntity;
import com.lst.projectlib.entity.Msg;

import org.json.JSONObject;

import okhttp3.Response;

/**
 * Created by sxy on 2017/11/2.
 */

public abstract class GetUserInfoCallBack extends MsgCallBack {
    @Override
    public Msg parseNetworkResponse(Response response, int i) throws Exception {
        Msg msg = super.parseNetworkResponse(response, i);
        JSONObject object = (JSONObject) msg.getData();
        if (object!=null) {
            UserEntity entity = new UserEntity();
            if (!object.isNull("Name")) {
                entity.setName(object.getString("Name"));
            }
            if (!object.isNull("LoginName")) {
                entity.setLoginName(object.getString("LoginName"));
            }
            if (!object.isNull("Phone")) {
                entity.setPhone(object.getString("Phone"));
            }
            if (!object.isNull("IdNumber")) {
                entity.setIdNumber(object.getString("IdNumber"));
            }
            if (!object.isNull("RefereeId")) {
                entity.setRefereeId(object.getString("RefereeId"));
            }
            if (!object.isNull("FirstDesc")) {
                entity.setFirstDesc(object.getString("FirstDesc"));
            }
            if (!object.isNull("Id")) {
                entity.setId(object.getString("Id"));
            }
            msg.setData(entity);
        }
        return msg;
    }
}
